package com.feihao.zhou.TCP.demo02Again;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class ClientDemo {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 10086);
        BufferedReader br = null;
        Scanner scanner = new Scanner(System.in);

        String s = scanner.next();
        System.out.println("输入你想说的话吧：");
        //写文字：
        OutputStream os = socket.getOutputStream();
        os.write(s.getBytes());
        //流写完关闭socket的写入流：
        socket.shutdownOutput();

        //读取：
        br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String len;
        while ((len = br.readLine()) != null) {
            System.out.println(len);
        }

        br.close();


    }
}
